/*
 * Copyright (c) 2022  by Junzhao
 * THIS FILE IS PART OF JAVASE Song Huongkang PROJECT
 * All Rights Reserved.
 */

package 练习.银行账户管理;

class Account {
    // 属性
    private int id;//账户id
    private double balance;//账户余额
    private double annualInterestRate;//年利率

    // 构造方法

    public Account(int id, double balance, double annualInterestRate) {
        this.id = id;
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
    }

    // 类的方法
    public void drawMoney(double amount) {// 取钱
        if (amount > balance) {
            System.out.println("您的余额不足，取款失败。");
        } else {
            System.out.println("您取出了" + amount + "￥现在的余额为:" + (balance - amount) + "￥");
            this.balance = balance - amount;
        }
    }

    public void saveMoney(double amount) {// 存钱
        System.out.println("您存入了" + amount + "￥现在的余额为:" + (balance + amount) + "￥");
        this.balance = balance + amount;
    }


    // get set方法
    public void setBalance(double balance) {
        this.balance = balance;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public double getBalance() {
        return balance;
    }

    public int getId() {
        return id;
    }


}
